<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新闻列表</title>
    <!--<script type="text/javascript" src="lib/js/jquery-3.2.1.min.js"></script>-->
    <!--<script type="text/javascript" src="lib/js/bootstrap.min.js"></script>-->
    <!--<link rel="stylesheet" href="lib/css/bootstrap.min.css">-->
    <!--<link rel="stylesheet" href="lib/layui/css/layui.css">-->
    <!--<link rel="stylesheet" href="app/css/tablegroup.css">-->
    <!--<script type="text/javascript" src="lib/js/jquery.data2excel.js"></script>-->
    <!--<script type="text/javascript" src="lib/layui/layui.js"></script>-->
</head>
<body>
    <div class="container">
        <table class="layui-table" id="newstable" lay-filter="newstable">

    </div>

</table>
</body>
</html>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate','table'], function(){
        var tableData;

        var table = layui.table;
        table.render({
            elem: '#newstable',
            url:'/libms/newstable.json',
            page:true,
            cols: [[
                {field:'title',  title: '标题'},
                {field:'content',  title: '内容', },
                {field:'time',  title: '时间', },
                {field:'auth',  title: '发布者', },
                {fixed: 'right', width:200, align:'center', toolbar: '#barDemo',  title: '操作'}

            ]],

            done: function(res, curr, count){
                tableData = res;
            }


        });
        table.on('tool(newstable)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });
    });
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>

</script>